package com.dime.basic.api.factory;

import com.dime.basic.api.RemoteBaseCombService;
import com.dime.basic.api.domain.DimeBasecomb;
import com.dime.basic.api.model.Combo;
import com.dime.basic.api.model.ComboBase;
import com.dime.basic.api.model.DimeBasicDataResult;
import com.dime.basic.api.model.HarmCombo;
import com.ruoyi.common.core.domain.R;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class RemoteBaseCombFallbackFactory implements FallbackFactory<RemoteBaseCombService> {
    private static final Logger log = LoggerFactory.getLogger(RemoteBaseCombFallbackFactory.class);

    @Override
    public RemoteBaseCombService create(Throwable throwable) {
        log.error("蝶美基础信息服务调用失败:{}", throwable.getMessage());
        return new RemoteBaseCombService() {

            @Override
            public R<List<ComboBase>> getCombs(Combo requestBody, String source) {
                return R.fail("查询Comb列表:" + throwable.getMessage());
            }

            @Override
            public R<Combo> getComb(String combCode, String source) {
                return R.fail("查询Comb详细信息:" + throwable.getMessage());
            }

            @Override
            public R<DimeBasicDataResult> checkCombos(List<ComboBase> combos, String source) {
                return R.fail("检查Comb信息是否正确:" + throwable.getMessage());
            }

            @Override
            public R<List<ComboBase>> getCombosByCodes(String combCodes, String source) {
                return R.fail("根据combCode查询Combo:" + throwable.getMessage());
            }

            @Override
            public R<List<HarmCombo>> getComboByHarmIds(String[] harmids, String source) {
                return R.fail("根据危害查询Combo:" + throwable.getMessage());
            }

            @Override
            public R<List<DimeBasecomb>> getComboByIds(String[] ids) {
                return R.fail("根据ids查询Combo:" + throwable.getMessage());
            }
        };
    }
}


